var t = require("../export.js");

getApp();

Page({
    data: {
        UserInfo: [],
        region: [],
        reg: 0,
        date: "",
        MaintainList: [],
        index: 0
    },
    onLoad: function(t) {
        this.getUserInfo(t), this.getMaintainList(t), this.getExplain(t);
        Date.parse(new Date());
        var a = new Date(), n = a.getFullYear(), i = a.getMonth(), e = a.getDate();
        this.setData({
            Y: n,
            m: i + 1,
            d: e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    getUserInfo: function(a) {
        var n = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getUserInfo.html", a, function(t) {
            console.log(t), console.log(111111111111), 0 == t.flag ? wx.showModal({
                title: "提示",
                showCancel: !0,
                content: "绑定爱车可自动获取基本信息",
                success: function(t) {
                    t.confirm && wx.navigateTo({
                        url: "/pages/car/add-car/add-car"
                    });
                }
            }) : n.setData({
                UserInfo: t
            });
        });
    },
    getMaintainList: function(a) {
        var n = this, i = {
            options: a,
            type_id: 0
        };
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getMaintainList.html", i, function(t) {
            n.setData({
                MaintainList: t
            });
        });
    },
    bindRegionChange: function(t) {
        this.setData({
            region: t.detail.value,
            reg: 1
        });
    },
    ChangeDate: function(t) {
        this.setData({
            date: t.detail.value
        });
    },
    bindPickerChange: function(t) {
        var a = t.detail.value;
        this.setData({
            index: a
        });
    },
    formSubmit: function(a) {
        var n = this, i = a.detail.value;
        i.type_id = this.data.MaintainList[this.data.index].id;
        var e = i;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Apiform/addMaintain.html", e, function(t) {
            n.addMaintain(t);
        }, this, {});
    },
    addMaintain: function(t) {
        wx.showModal({
            title: "提示",
            content: t.info,
            showCancel: !1,
            complete: function(t) {
                wx.navigateTo({
                    url: "/pages/car/my-bespeak/my-bespeak",
                    fail: function(t) {
                        wx.switchTab({
                            url: "/pages/car/index/index"
                        });
                    }
                });
            }
        });
    },
    getExplain: function(a) {
        var n = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getExplain.html", a, function(t) {
            console.log(t), n.setData({
                Explain: t.explain,
                coupon: t.coupon
            });
        });
    }
});